﻿using System;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace ArtMath.Window
{
    public partial class TerminalWindow : DockContent
    {
        public TerminalWindow()
        {
            InitializeComponent();
        }

        private void tsbRun_Click(object sender, EventArgs e)
        {
            SketchPad pad = Program.WinDocuments.LinkedDocument?.SelectedPad;
            if (pad == null) return;
            //foreach (string ln in tbCommands.Lines)
            //{
            //    string[] parts = ln.Split(' ');
            //    if (parts.Length == 0) continue;
            //    switch (parts[0])
            //    {
            //        case "crt":
            //            int clickTimes = 0;
            //            switch (parts[1])
            //            {
            //                case "ldxd":
            //                    pad.HostObj = new TwoPointsLineSegment(pad, parts[2]);
            //                    clickTimes = 2;
            //                    break;
            //                case "hs":
            //                    pad.HostObj = new Function(pad, parts[2], ToolTypeName.hs, parts[4], parts[3]);
            //                    break;
            //            }
            //            if (clickTimes == 0)
            //            {
            //                pad.TryCreateObject(pad.HostObj);
            //            }
            //            else
            //            {
            //                for (int i = parts.Length - clickTimes; i < parts.Length; i++)
            //                {
            //                    PointD Pxy = pad.MathToPxy(PointD.FromString(parts[i]));
            //                    pad.HostTrackComponentBuilding(Pxy);
            //                    if (!pad.TryCreateObject(pad.HostObj))
            //                    {
            //                        break;
            //                    }
            //                }
            //            }
            //            break;
            //    }
            //}
        }

        private void TerminalWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                DockState = DockState.Hidden;
                e.Cancel = true;
            }
            Program.WinMain.CommandMenu.Checked = false;
        }
    }
}
